<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>用户管理</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link href="css/style.css" rel="stylesheet">
</head>

<body>
    <div id="main-data" class="">
        <div class="panel panel-default">
            <div class="panel-heading">用户管理</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-sm-10">
                        <div class="col-sm-3">
                            <input v-model="query.stuID" type="text" class="form-control" placeholder="用户名">
                        </div>
                        <div class="col-sm-3">
                            <span>部门：</span>
                            <select v-model="query.deptId" class="form-control form-select" name="dept">
                                <option v-bind:value="dept.deptId" v-for="dept in depts">{{ dept.deptName }}</option>
                                <option v-bind:value="dept.deptId">全部</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-2">
                        <button class="btn btn-default" v-on:click="queryData('all')">查询</button>
                    </div>
                </div>
            </div>
            <div class="panel-body">
                <table class="table table-bordered mt-10">
                    <tr>
                        <th>登录名</th>
                        <th>部门</th>
                        <th>ID</th>
                        <th>角色</th>
                        <th>编辑</th>
                    </tr>
                    <tr v-for="item in items" track-by="$index">
                        <td>{{item.loginName}}</td>
                        <td>{{item.deptId}}</td>
                        <td>{{item.id}}</td>
                        <td>{{roles[item.role].name}}</td>
                        <td>
                            <button class="btn btn-default" data-toggle="modal" data-target="#myModal-edit" v-on:click="editUser(item.id)">编辑</button>
                            <button class="btn btn-default" data-toggle="modal" v-on:click="delUser(item.id,item.loginName,item.deptId)" data-target="#myModal-del">删除</button>
                        </td>
                    </tr>
                </table>
                <div>
                    <button class="btn btn-default" data-toggle="modal" data-target="#myModal-add">添加</button>
                </div>
            </div>
        </div>
        <!-- 添加模态框（Modal） -->
        <div class="modal fade" id="myModal-add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">添加用户</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-4" for="">登录名：</label>
                                <div class="col-sm-8">
                                    <input v-model="newItem.loginName" type="text" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4" for="">部门：</label>
                                <div class="col-sm-8">
                                    <select v-model="newItem.deptId" class="form-control form-select" name="dept">
                                        <option v-bind:value="dept.deptId" v-for="dept in depts">{{ dept.deptName }}</option>
                                        <option v-bind:value="dept.deptId">全部</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" v-on:click="addUser" class="btn btn-primary">确定添加</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
        <!-- 编辑模态框（Modal） -->
        <div class="modal fade" id="myModal-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">编辑用户</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-4" for="">登录名：</label>
                                <p>{{editItem.name}}</p>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4" for="">部门：</label>
                                <div class="col-sm-8">
                                    <select v-model="editItem.deptId" class="form-control form-select" name="dept">
                                        <option v-bind:value="dept.deptId" v-for="dept in depts">{{ dept.deptName }}</option>
                                        <option v-bind:value="dept.deptId">全部</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4" for="">角色：</label>
                                <div class="col-sm-8">
                                    <select v-model="editItem.roleId" class="form-control form-select" name="dept">
                                        <option v-bind:value="role.id" v-for="role in roles">{{ role.name }}</option>
                                        <option v-bind:value="dept.deptId">全部</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" v-on:click="addUser" class="btn btn-primary">确定添加</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
        <!-- 删除模态框（Modal） -->
        <div class="modal fade" id="myModal-del" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">删除</h4>
                    </div>
                    <div class="modal-body">
                        <p>确认删除用户：{{delItem.name}}</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" v-on:click="confirmDel" class="btn btn-primary">确定删除</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
    </div>
</body>
<script type="text/javascript" src="js/dist/jquery-2.2.4.js"></script>
<script type="text/javascript" src="js/dist/bootstrap.min.js"></script>
<script type="text/javascript" src="js/dist/vue.js"></script>
<script type="text/javascript" src="js/dist/md5.min.js"></script>
<script type="text/javascript" data-main="js/user.js" src="js/dist/require.js"></script>

</html>
